package com.neusoft.tijian.config;

/**
 * 统一响应结果类
 */
public class Result {
    private boolean success;    // 操作是否成功
    private Object data;        // 响应数据
    private String message;     // 响应消息

    // 私有构造方法，防止直接实例化
    private Result() {}

    // 成功响应，带数据和消息
    public static Result success(Object data, String message) {
        Result result = new Result();
        result.success = true;
        result.data = data;
        result.message = message;
        return result;
    }

    // 成功响应，只带数据
    public static Result success(Object data) {
        return success(data, "操作成功");
    }

    // 成功响应，不带数据
    public static Result success() {
        return success(null, "操作成功");
    }

    // 错误响应
    public static Result error(String message) {
        Result result = new Result();
        result.success = false;
        result.data = null;
        result.message = message;
        return result;
    }

    // getter方法
    public boolean isSuccess() {
        return success;
    }

    public Object getData() {
        return data;
    }

    public String getMessage() {
        return message;
    }
}
